

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>pysimm.models.monomers.gaff.pe &mdash; pysimm 0.2 documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../../../../_static/css/theme.css" type="text/css" />
  

  

  
    <link rel="top" title="pysimm 0.2 documentation" href="../../../../../index.html"/>
        <link rel="up" title="pysimm" href="../../../../pysimm.html"/> 

  
  <script src="../../../../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../../../../index.html" class="icon icon-home"> pysimm
          

          
          </a>

          
            
            
              <div class="version">
                0.2
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../../pysimm.html">pysimm package</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../../../../../index.html">pysimm</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          





<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../../../../../index.html">Docs</a> &raquo;</li>
      
          <li><a href="../../../../index.html">Module code</a> &raquo;</li>
      
          <li><a href="../../../../pysimm.html">pysimm</a> &raquo;</li>
      
    <li>pysimm.models.monomers.gaff.pe</li>
      <li class="wy-breadcrumbs-aside">
        
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for pysimm.models.monomers.gaff.pe</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">system</span><span class="p">,</span> <span class="n">lmps</span><span class="p">,</span> <span class="n">forcefield</span>
<span class="kn">from</span> <span class="nn">pysimm.apps.random_walk</span> <span class="kn">import</span> <span class="n">random_walk</span>

<div class="viewcode-block" id="monomer"><a class="viewcode-back" href="../../../../../pysimm.models.monomers.gaff.pe.html#pysimm.models.monomers.gaff.pe.monomer">[docs]</a><span class="k">def</span> <span class="nf">monomer</span><span class="p">():</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">read_pubchem_smiles</span><span class="p">(</span><span class="s1">&#39;CC&#39;</span><span class="p">)</span>
    <span class="k">except</span><span class="p">:</span>
        <span class="kn">import</span> <span class="nn">os</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">system</span><span class="o">.</span><span class="n">read_mol</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)),</span> <span class="n">os</span><span class="o">.</span><span class="n">pardir</span><span class="p">,</span> <span class="s1">&#39;CC.mol&#39;</span><span class="p">))</span>
    <span class="n">f</span> <span class="o">=</span> <span class="n">forcefield</span><span class="o">.</span><span class="n">Gaff</span><span class="p">()</span>
    <span class="n">s</span><span class="o">.</span><span class="n">apply_forcefield</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
    
    <span class="n">c1</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
    <span class="n">c2</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
    <span class="n">c1</span><span class="o">.</span><span class="n">linker</span> <span class="o">=</span> <span class="s1">&#39;head&#39;</span>
    <span class="n">c2</span><span class="o">.</span><span class="n">linker</span> <span class="o">=</span> <span class="s1">&#39;tail&#39;</span>
    
    <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">c1</span><span class="o">.</span><span class="n">bonds</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span> <span class="ow">or</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span><span class="p">:</span>
            <span class="n">pb</span> <span class="o">=</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span> <span class="k">if</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span> <span class="ow">is</span> <span class="n">c1</span> <span class="k">else</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span>
            <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">pb</span><span class="o">.</span><span class="n">tag</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
            <span class="k">break</span>
        
    <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">c2</span><span class="o">.</span><span class="n">bonds</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span> <span class="ow">or</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span><span class="o">.</span><span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;H&#39;</span><span class="p">:</span>
            <span class="n">pb</span> <span class="o">=</span> <span class="n">b</span><span class="o">.</span><span class="n">a</span> <span class="k">if</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span> <span class="ow">is</span> <span class="n">c2</span> <span class="k">else</span> <span class="n">b</span><span class="o">.</span><span class="n">b</span>
            <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">pb</span><span class="o">.</span><span class="n">tag</span><span class="p">,</span> <span class="n">update</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
            <span class="k">break</span>
            
    <span class="n">s</span><span class="o">.</span><span class="n">remove_spare_bonding</span><span class="p">()</span>
    
    <span class="n">lmps</span><span class="o">.</span><span class="n">quick_min</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">min_style</span><span class="o">=</span><span class="s1">&#39;fire&#39;</span><span class="p">)</span>
    
    <span class="n">s</span><span class="o">.</span><span class="n">add_particle_bonding</span><span class="p">()</span>
    
    <span class="k">return</span> <span class="n">s</span></div>
    
<div class="viewcode-block" id="polymer_chain"><a class="viewcode-back" href="../../../../../pysimm.models.monomers.gaff.pe.html#pysimm.models.monomers.gaff.pe.polymer_chain">[docs]</a><span class="k">def</span> <span class="nf">polymer_chain</span><span class="p">(</span><span class="n">length</span><span class="p">):</span>
    <span class="n">mon</span> <span class="o">=</span> <span class="n">monomer</span><span class="p">()</span>
    <span class="n">polym</span> <span class="o">=</span> <span class="n">random_walk</span><span class="p">(</span><span class="n">mon</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="n">forcefield</span><span class="o">=</span><span class="n">forcefield</span><span class="o">.</span><span class="n">Gaff</span><span class="p">())</span>
    <span class="k">return</span> <span class="n">polym</span></div>
</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, https://pysimm.org.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../../../../',
            VERSION:'0.2',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="../../../../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../../../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../../../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../../../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>